<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>

<form id="form_usuario" action="<?php echo url_for('usuario/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php if (!$form->getObject()->isNew()): ?>
<input type="hidden" name="sf_method" value="put" />
<input type="hidden" name="id" value="<?php echo $form->getObject()->getId() ?>" />
<?php endif; ?>
	<?php echo $form->renderHiddenFields() ?>
  <table class="form">
    <tbody>
      <tr><th colspan="2" class="title">Dados usuario</th></tr>
      <?php echo $form->renderGlobalErrors() ?>
      <tr>
        <th><?php echo $form['username']->renderLabel() ?></th>
        <td>
          <?php echo $form['username'] ?>
          <?php echo form_error('usuario[username]'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['algorithm']->renderLabel() ?></th>
        <td>
          <?php echo $form['algorithm'] ?>
          <?php echo form_error('usuario[algorithm]'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['salt']->renderLabel() ?></th>
        <td>
          <?php echo $form['salt'] ?>
          <?php echo form_error('usuario[salt]'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['password']->renderLabel() ?></th>
        <td>
          <?php echo $form['password'] ?>
          <?php echo form_error('usuario[password]'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['is_active']->renderLabel() ?></th>
        <td>
          <?php echo $form['is_active'] ?>
          <?php echo form_error('usuario[is_active]'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['is_super_admin']->renderLabel() ?></th>
        <td>
          <?php echo $form['is_super_admin'] ?>
          <?php echo form_error('usuario[is_super_admin]'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['last_login']->renderLabel() ?></th>
        <td>
          <?php echo $form['last_login'] ?>
          <?php echo form_error('usuario[last_login]'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['created_at']->renderLabel() ?></th>
        <td>
          <?php echo $form['created_at'] ?>
          <?php echo form_error('usuario[created_at]'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['updated_at']->renderLabel() ?></th>
        <td>
          <?php echo $form['updated_at'] ?>
          <?php echo form_error('usuario[updated_at]'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['groups_list']->renderLabel() ?></th>
        <td>
          <?php echo $form['groups_list'] ?>
          <?php echo form_error('usuario[groups_list]'); ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['permissions_list']->renderLabel() ?></th>
        <td>
          <?php echo $form['permissions_list'] ?>
          <?php echo form_error('usuario[permissions_list]'); ?>
        </td>
      </tr>
    </tbody>
  </table>
</form>

<?php
	comandos_form(
		link_to(
			':: Listar ::',
			'usuario/list',
			array('class' => 'botao')
		),
		button_to_function(
			':: Salvar ::',
			"$('#form_usuario').submit()",
			array('class' => 'botao')
		)
	);
?>